package com.sort;

import java.util.Arrays;

/**
 * @Author: codermzy
 * @Date: 2024/02/03/13:21
 * @Description:
 */
public class Code05_GetMax {

    public static int getMax(int[] arr) {
        return process(arr, 0, arr.length - 1);
    }

    private static int process(int[] arr, int L, int R) {
        if (arr[L] == arr[R]) {
            return arr[L];
        }

        int mid = L + ((R - L) / 2);
        int leftMax = process(arr, L, mid);
        int rightMax = process(arr, mid + 1, R);
        return Math.max(leftMax, rightMax);
    }


    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,67,7,8};
        int max = getMax(arr);
        System.out.println(max);
    }
}
